Tuesday, July 31, 2007

First bits of PyQt

Yesterday I wrote my first PyQt application. It is really simple program, called "tray", which lives in system tray and notifies user of new messages at my favorite social network Vkontakte.ru (Russian clone of FaceBook.com).
The program is less than 170 lines of code. You can try it if you are registered at vkontakte.ru, but the program doesn't matter now.
I am very pleased with simplicity of creation of portable rich GUI applications with PyQt, but as always there are some issues on Windows. I created the program on my favorite old Linux box with vim, so there I had no problems with PyQt4 installation and no need of packaging, because the program consists of one file and three icons.
Then I decided to try it on Windows. First of all I installed newest PyQt 4.3.0. This new version is now packed in self-installing archive, which includes Qt and Eric4 IDE, so now you shouldn't have problems which I described in this post.
After that the program worked perfectly, but I needed to create standalone version for people who don't have Python and PyQt on their PCs.
This is rather simple task, but I've spent several hours fighting some issues.
I used py2exe to create standalone executable. The problem was to include PyQt into it. The idea is simple: I needed to specify that PyQt should be included. So I used solution from py2exe.org. I created file called setup.py with following contents:

from distutils.core import setup
import py2exe
setup(windows=[{"script":"tray.py"}], options={"py2exe":{"includes":["sip"]}})

Then I ran python setup.py install py2exe.
But I received errors like "module import failed: _qt". So I decided to mention inclusion explicitly: python setup.py install py2exe --includes=PyQt4,sip. It didn't help, but error message changed to "cannot find QApplication". Then I tried to reorganize imports in my code:

import sys
from PyQt4.Qt import *
from PyQt4 import QtCore, QtGui

gave correct result, and the executable was created.
I believe that this problem with imports is temporary and will be fixed in near future.

So then I used Inno Setup to create setup package and it was really easy.

Conclusion
It is really easy to create portable applications with great GUI with PyQt4.
The only trade off is the size of installed application on Windows: for my 170 lines of code project I've got 5 Mb setup package, which extracts into 17 Mb application.
The reason is simple - lack of common packaging system with dependencies on Windows, so the program needs it's own copy of Python and PyQt.

Labels: , , , , , ,

Wednesday, May 9, 2007

Fit2PDA

I've finally chosen the name for my program.
So it is now called Fit2PDA.

I think that the name is apt to the program :)

I've done some additional improvements in GUI, so now you can see (rather accurate:) progress bars during conversion and you can convert not only PDF/PostScript, but also Djvu.

Big number of free scanned ebooks can be found in Kolhoz library and eDonkey2000 p2p-network.

By the way, there are 2 good compatible clients for eDonkey: eMule for Windows and aMule for Linux. So, if you use both operation systems, you can continue your emule downloads in amule. You just need to select the same working directory!

Labels: , , , , , , ,

Thursday, April 12, 2007

Just finished reading the book

Couple of days ago I finished reading the book "Advanced Linux Programming".
It is old but excellent book on programming in GNU/Linux environment. It starts from brief description of everyday developer's tools such as emacs, gcc, gdb, make and then leads to core topics of Linux development. It covers main system calls, IPC, networking, usage of shared libraries and plugins, error handling and so on.
So it is really useful for experienced developers and even for beginners because the text is very clear. There is no information on GUI development and minor libraries, so the book is very useful even six years after the publication.
It can be downloaded from the official site

I was doing some marks when reading, so I created some kind of reference card page on some covered in the book. You can find it here

Labels: , , ,